home *** CD-ROM | disk | FTP | other *** search
- /*
- * $Id: drag_limit_test.java,v 1.15 1996/10/03 19:46:51 hudson Exp $
- * $Author: hudson $
- */
-
- package sub_arctic.test;
-
- import sub_arctic.lib.interactor;
- import sub_arctic.lib.interactor_applet;
- import sub_arctic.lib.manager;
- import sub_arctic.lib.interactor_consts;
- import sub_arctic.lib.top_level;
- import sub_arctic.lib.base_parent_interactor;
- import sub_arctic.lib.button;
- import sub_arctic.lib.drag_icon;
- import sub_arctic.lib.std;
- import sub_arctic.lib.backdrop;
- import sub_arctic.lib.line_display;
- import sub_arctic.lib.row;
- import sub_arctic.lib.text_toggle_collection;
- import sub_arctic.lib.toggle;
- import sub_arctic.lib.icon;
- import sub_arctic.input.std_drag_filters;
- import sub_arctic.input.event;
- import sub_arctic.input.callback_object;
- import sub_arctic.input.pressable;
- import sub_arctic.input.move_draggable;
- import sub_arctic.output.loaded_image;
- import sub_arctic.output.style;
- import sub_arctic.output.style_manager;
-
- import java.awt.Point;
- import java.awt.Rectangle;
-
- public class drag_limit_test extends interactor_applet
- implements interactor_consts, callback_object {
-
- public static int setting = 0;
-
- /**
- * Shorthand for generating a button's image in the default style.
- */
- public static loaded_image[] std_label(String s) {
- style st=style_manager.current_style();
- return st.button_make_images(s,style_manager.default_font(),10,5,false);
- }
-
- public void callback(interactor from_obj, event evt, int cb_n, Object info)
- {
- int i = ((Integer)from_obj.user_info()).intValue();
- System.out.println("setting = " + (i-1));
- setting = i-1;
- }
-
- public void build_ui(base_parent_interactor top)
- {
- row r;
- String labels[] = {
- "\"Grab\" point", "Top-left", "Top-right", "Bottom-left",
- "Bottom-right", "Center"};
-
- r = new row(5, 5, true, false, row.CENTER_JUSTIFIED);
- top.add_child(r);
- r.add_child(new text_toggle_collection(labels, true, -1, this));
- ((toggle)(r.child(0).child(1))).set_cur_state(1);
-
- base_parent_interactor p1 = new base_parent_interactor(10,10,380,380);
- r.add_child(p1);
- p1.add_child(new backdrop(400,400,std.stipple25()));
-
- loaded_image[] lab1 = std_label("Limited to parent less 10,20");
- drag_icon_t1 drag = new drag_icon_t1(10,10,lab1[0]);
- p1.add_child(drag);
-
- lab1 = std_label("Limited to rect 50,50:200x100");
- drag_icon_t2 drag2 = new drag_icon_t2(60,60,lab1[0]);
- p1.add_child(drag2);
-
- line_display ln = new line_display(50,50,250,50,0);
- p1.add_child(ln);
- ln = new line_display(50,50,50,150,0);
- p1.add_child(ln);
- ln = new line_display(250,50,250,150,0);
- p1.add_child(ln);
- ln = new line_display(50,150,250,150,0);
- p1.add_child(ln);
-
- ln = new line_display(0,p1.h()-20,p1.w()-10,p1.h()-20,0);
- p1.add_child(ln);
-
- ln = new line_display(p1.w()-10,0,p1.w()-10,p1.h()-20,0);
- p1.add_child(ln);
-
- ln = new line_display(10,300,350,20,0);
- p1.add_child(ln);
-
- lab1 = std_label("Limited to line");
- drag_icon_t3 drag3 = new drag_icon_t3(10,300,lab1[0]);
- p1.add_child(drag3);
-
- lab1 = std_label("w/ debug output (slow)");
- drag_icon_t4 drag4 = new drag_icon_t4(200,10,lab1[0]);
- p1.add_child(drag4);
- }
- }
-
- class drag_icon_t1 extends icon implements pressable, move_draggable {
- public drag_icon_t1(int x, int y, loaded_image img)
- {super(x,y,img);}
- public int drag_feature_point()
- {
- return drag_limit_test.setting;
- }
- public Point filter_pt(Point orig_pt, interactor drag_obj, Point f_pt)
- {
- return std_drag_filters.limit_to_parent(orig_pt,this,true,10,20, f_pt);
- }
- public boolean press(event evt, Object user_info)
- {
- manager.move_drag_focus.set_focus_to(this, evt, user_info);
- return true;
- }
- public boolean release(event evt, Object user_info)
- {
- return true;
- }
- public boolean drag_start(
- event evt, int xv, int yv, int gx, int gy, Object user_info)
- { return true; }
- public boolean drag_feedback(
- event evt,
- int x_pos, int y_pos,
- int start_x, int start_y,
- int grab_x, int grab_y,
- Object user_info)
- {
- /* move our position */
- set_pos(x_pos, y_pos);
- return true;
- }
- public boolean drag_end(
- event evt,
- int x_pos, int y_pos,
- int start_x, int start_y,
- int grab_x, int grab_y,
- Object user_info)
- {
- /* let drag_feedack to all the work */
- return drag_feedback(evt, x_pos, y_pos, start_x, start_y, grab_x, grab_y,
- user_info);
- }
- }
-
- class drag_icon_t2 extends drag_icon_t1 {
- public drag_icon_t2(int x, int y, loaded_image img)
- {super(x,y,img);}
- public static Rectangle r = new Rectangle(50,50, 200,100);
- public Point filter_pt(Point orig_pt, interactor drag_obj, Point f_pt)
- {
- return std_drag_filters.limit_to_rect(orig_pt,r);
- }
- }
-
- class drag_icon_t3 extends drag_icon_t1 {
- public drag_icon_t3(int x, int y, loaded_image img)
- {super(x,y,img);}
- public Point filter_pt(Point orig_pt, interactor drag_obj, Point f_pt)
- {
- return std_drag_filters.limit_to_line_seg(orig_pt, 10, 300, 350,20);
- }
- }
-
- class drag_icon_t4 extends drag_icon_t1 {
-
- public drag_icon_t4(int x, int y, loaded_image img)
- {super(x,y,img);}
-
- public boolean drag_start(
- event evt,
- int x, int y,
- int grab_x, int grab_y,
- Object user_info)
- {
- System.out.println("drag_start(evt, " +
- "x="+ x + "," + "y=" + y + "," +
- "grab_x="+ grab_x + "," + "grab_y=" + grab_y + "," +
- "user_info");
- return super.drag_start(evt,x,y,grab_x,grab_y,user_info);
- }
-
- public boolean drag_feedback(
- event evt,
- int x, int y,
- int start_x, int start_y,
- int grab_x, int grab_y,
- Object user_info)
- {
- System.out.println("drag_feedback(evt, " +
- "x="+ x + "," + "y=" + y + "," +
- "start_x="+ start_x + "," + "start_y=" + start_y + "," +
- "grab_x="+ grab_x + "," + "grab_y=" + grab_y + "," +
- "user_info");
- return
- super.drag_feedback(evt,x,y,start_x,start_y,grab_x,grab_y,user_info);
- }
-
- public boolean drag_end(
- event evt,
- int x, int y,
- int start_x, int start_y,
- int grab_x, int grab_y,
- Object user_info)
- {
- System.out.println("drag_end(evt, " +
- "x="+ x + "," + "y=" + y + "," +
- "start_x="+ start_x + "," + "start_y=" + start_y + "," +
- "grab_x="+ grab_x + "," + "grab_y=" + grab_y + "," +
- "user_info");
- return super.drag_end(evt,x,y,start_x,start_y,grab_x,grab_y,user_info);
- }
- }
-
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-